package com.tyjc.unique.dlt;

import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.RadioButton;

import com.tyjc.unique.common.DLTZouShiInfors;
import com.tyjc.unique.view.ZouShiOnDraw;
import com.tyjc.unique.view.dlt.OnDrawBottom;
import com.tyjc.unique.view.dlt.OnDrawCenter;
import com.tyjc.unique.view.dlt.OnDrawLeft;
import com.tyjc.unique.view.dlt.OnDrawTop;
import com.tyjc.lottery.R;
import com.fyzk.utils.LotteryIDUtils;

import org.xutils.view.annotation.ContentView;

@ContentView(R.layout.fg_ssq_zst)
public class DLTThendFragment extends ZouShiAnalaysesBaseFragment {

    private OnDrawCenter center_onDraw;
    private OnDrawTop onDrawTop;
    private OnDrawLeft onDrawLeft;
    private OnDrawBottom onDrawBottom;

    private RadioButton red_Radio;
    private RadioButton blue_Radio;



    @Override
    public void initView(View view) {
        super.initView(view);
        isZX = false;

        red_Radio = (RadioButton) view.findViewById(R.id.zst_radio_red);
        blue_Radio = (RadioButton) view.findViewById(R.id.zst_radio_blue);
        red_Radio.setOnCheckedChangeListener(this);
        blue_Radio.setOnCheckedChangeListener(this);
    }

    @Override
    protected ZouShiOnDraw getTopOnDraw() {
        onDrawTop = new OnDrawTop(getContext());
        onDrawTop.setInfors(null);
        return onDrawTop;
    }

    @Override
    protected ZouShiOnDraw getBottomOnDraw() {
        onDrawBottom = new OnDrawBottom(getContext());
        onDrawBottom.setInfors(null);
        return onDrawBottom;
    }

    @Override
    protected ZouShiOnDraw getLeftOnDraw() {
        onDrawLeft = new OnDrawLeft(getContext());
        onDrawLeft.setInfors(null);
        return onDrawLeft;
    }

    @Override
    protected ZouShiOnDraw getCenterOnDraw() {
        center_onDraw = new OnDrawCenter(getContext());
        center_onDraw.setInfors(null);
        center_onDraw.setQiu_btm(R.drawable.hongqiu_check);
        return center_onDraw;
    }


    @Override
    protected void change(int[][] kj) {
        if (onDrawTop == null) {
            onDrawTop = (OnDrawTop) getTopOnDraw();
        }

        if (onDrawBottom == null) {
            onDrawBottom = (OnDrawBottom) getBottomOnDraw();
        }
        if (center_onDraw == null) {
            center_onDraw = (OnDrawCenter) getCenterOnDraw();
        }
        if(onDrawLeft == null){
            onDrawLeft = (OnDrawLeft) getLeftOnDraw();
        }

        onDrawTop.setInfors(kj);
        onDrawBottom.setInfors(kj);

        center_onDraw.setInfors(kj);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1);
        center_onDraw.setLayoutParams(lp);
        center_onDraw.isShowZheXian = isZX;
        center_onDraw.isShowYiLou = isYL;

        onDrawLeft.arrayChartItems = arrayChartItems;
        onDrawLeft.setInfors(kj);
    }


    @Override
    public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
        switch (arg0.getId()) {
            case R.id.zst_radio_red:
                if (arg1) {
                    type = 0;
                    center_onDraw.setQiu_btm(R.drawable.hongqiu_check);
                    center_onDraw.type = 0;
                    change(DLTZouShiInfors.getZouShi(arrayChartItems, type));
                }
                break;
            case R.id.zst_radio_blue:
                if (arg1) {
                    type = 1;
                    center_onDraw.setQiu_btm(R.drawable.lanqiu_check);
                    center_onDraw.type = 1;
                    change(DLTZouShiInfors.getZouShi(arrayChartItems, type));
                }
                break;
            default:
                break;
        }
    }

    @Override
    protected int getLotteryType() {
        return LotteryIDUtils.DLT_LOTTERY_ID_INT;
    }


}
